package com.neusoft.hifly.attachment.file.entity;

import java.io.Serializable;
import java.time.LocalDateTime;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

import com.neusoft.hifly.commons.lang.LocalDateUtil;
import com.neusoft.hifly.core.utils.GlobalConstants;

/**
 * Title: 附件服务
 * <p>
 * Description: 附件_附件表历史记录对象
 * <p>
 * Copyright: 2019
 * <p>
 * Company: 东软汉枫
 *
 * @author lh_neu
 * @version 1.0.0
 */
@JsonIgnoreProperties(ignoreUnknown = true)
@TableName(value = GlobalConstants.DYNAMIC_TABLE_NAME_PREFIX + "_FILE_LOG")
public class FileLogObj implements Serializable {
	private static final long serialVersionUID = -156136150200316L;
	// 主键
	@TableId(value = "ID", type = IdType.AUTO)
	private int id;
	// 租户逻辑ID
	@TableField(value = "ORGAN_LOGIC_ID")
	private long organLogicId;
	// 主附件逻辑ID
	@TableField(value = "FILE_LOGIC_ID")
	private long fileLogicId;
	// 附件与对象关联ID
	@TableField(value = "OBJ_LOGIC_ID")
	private long objLogicId;
	// 日志时间
	@TableField(value = "LOG_TIME")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonDeserialize(using = LocalDateTimeDeserializer.class)
	@JsonSerialize(using = LocalDateTimeSerializer.class)
	private LocalDateTime logTime;
	// 原文件名
	@TableField(value = "OLD_FILE_NAME")
	private String oldFileName;
	// 新文件名
	@TableField(value = "NEW_FILE_NAME")
	private String newFileName;
	// 文件长度(KB)
	@TableField(value = "FILE_LENGTH")
	private double fileLength;
	// 附件类型
	@TableField(value = "FILE_TYPE")
	private String fileType;
	// 文件路径
	@TableField(value = "PATH")
	private String path;
	// 文档上传时顺序号
	@TableField(value = "FILE_ORDER")
	private int fileOrder;
	// 全文批注：模版ID
	@TableField(value = "TEMP_ID")
	private long tempId;
	// 全文批注：文档类型
	@TableField(value = "DOC_TYPE")
	private String docType;
	// 上传附件服务器URL地址
	@TableField(value = "FILE_URL")
	private String fileUrl;
	// 上传人
	@TableField(value = "USER_ID")
	private long userId;
	// 文档修改日期
	@TableField(value = "CREATE_TIME")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonDeserialize(using = LocalDateTimeDeserializer.class)
	@JsonSerialize(using = LocalDateTimeSerializer.class)
	private LocalDateTime createTime;
	// 扩展字段1
	@TableField(value = "EXT1")
	private String ext1;
	// 扩展字段2
	@TableField(value = "EXT2")
	private String ext2;
	// 扩展字段3
	@TableField(value = "EXT3")
	private String ext3;
	// 扩展字段4
	@TableField(value = "EXT4")
	private String ext4;
	// 扩展字段5
	@TableField(value = "EXT5")
	private String ext5;

	// ################### 临时数据 ####################

	// 字符串类型的时间
	@TableField(exist = false)
	private String createTimeStr;
	// 字符串类型的时间
	@TableField(exist = false)
	private String logTimeStr;

	/**
	 * 得到对象的哈希值
	 *
	 * @return int 对象的哈希值
	 */
	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(this.getId()).toHashCode();
	}

	/**
	 * 比较两个对象是否相等
	 *
	 * @param other
	 *            要比较的对象
	 * @return boolean 相同返回true，否则返回flase
	 */
	@Override
	public boolean equals(final Object other) {
		if (!(other instanceof FileLogObj)) {
			return false;
		}
		final FileLogObj castOther = (FileLogObj) other;
		return new EqualsBuilder().append(this.getId(), castOther.getId()).isEquals();
	}

	/**
	 * 返回对象的字符串值
	 *
	 * @return String 表示用户对象的字符串值
	 */
	@Override
	public String toString() {
		return new ToStringBuilder(this).append("附件_附件表历史记录", this.getOldFileName() + "(" + this.getLogTimeStr() + ")")
				.toString();
	}

	/**
	 * 将DATE类型的时间格式化为字符串类型
	 *
	 * @author lh_neu
	 * @return 字符串时间
	 */
	public String getCreateTimeStr() {
		if (this.createTime != null) {
			this.createTimeStr = LocalDateUtil.showTime(this.createTime);
		}
		return this.createTimeStr;
	}

	/**
	 * 将DATE类型的时间格式化为字符串类型
	 *
	 * @author lh_neu
	 * @return 字符串时间
	 */
	public String getLogTimeStr() {
		if (this.logTime != null) {
			this.logTimeStr = LocalDateUtil.showTime(this.logTime);
		}
		return logTimeStr;
	}

	public String getFileType() {
		if (StringUtils.isNotEmpty(this.fileType)) {
			this.fileType = StringUtils.lowerCase(this.fileType);
		}
		return fileType;
	}

	public int getId() {
		return id;
	}

	public void setId(final int id) {
		this.id = id;
	}

	public long getOrganLogicId() {
		return organLogicId;
	}

	public void setOrganLogicId(final long organLogicId) {
		this.organLogicId = organLogicId;
	}

	public long getFileLogicId() {
		return fileLogicId;
	}

	public void setFileLogicId(final long fileLogicId) {
		this.fileLogicId = fileLogicId;
	}

	public long getObjLogicId() {
		return objLogicId;
	}

	public void setObjLogicId(final long objLogicId) {
		this.objLogicId = objLogicId;
	}

	public LocalDateTime getLogTime() {
		return logTime;
	}

	public void setLogTime(final LocalDateTime logTime) {
		this.logTime = logTime;
	}

	public String getOldFileName() {
		return oldFileName;
	}

	public void setOldFileName(final String oldFileName) {
		this.oldFileName = oldFileName;
	}

	public String getNewFileName() {
		return newFileName;
	}

	public void setNewFileName(final String newFileName) {
		this.newFileName = newFileName;
	}

	public double getFileLength() {
		return fileLength;
	}

	public void setFileLength(final double fileLength) {
		this.fileLength = fileLength;
	}

	public String getPath() {
		return path;
	}

	public void setPath(final String path) {
		this.path = path;
	}

	public int getFileOrder() {
		return fileOrder;
	}

	public void setFileOrder(final int fileOrder) {
		this.fileOrder = fileOrder;
	}

	public long getTempId() {
		return tempId;
	}

	public void setTempId(final long tempId) {
		this.tempId = tempId;
	}

	public String getDocType() {
		return docType;
	}

	public void setDocType(final String docType) {
		this.docType = docType;
	}

	public String getFileUrl() {
		return fileUrl;
	}

	public void setFileUrl(final String fileUrl) {
		this.fileUrl = fileUrl;
	}

	public long getUserId() {
		return userId;
	}

	public void setUserId(final long userId) {
		this.userId = userId;
	}

	public LocalDateTime getCreateTime() {
		return createTime;
	}

	public void setCreateTime(final LocalDateTime createTime) {
		this.createTime = createTime;
	}

	public String getExt1() {
		return ext1;
	}

	public void setExt1(final String ext1) {
		this.ext1 = ext1;
	}

	public String getExt2() {
		return ext2;
	}

	public void setExt2(final String ext2) {
		this.ext2 = ext2;
	}

	public String getExt3() {
		return ext3;
	}

	public void setExt3(final String ext3) {
		this.ext3 = ext3;
	}

	public String getExt4() {
		return ext4;
	}

	public void setExt4(final String ext4) {
		this.ext4 = ext4;
	}

	public String getExt5() {
		return ext5;
	}

	public void setExt5(final String ext5) {
		this.ext5 = ext5;
	}

	public void setFileType(final String fileType) {
		this.fileType = fileType;
	}

	public void setCreateTimeStr(final String createTimeStr) {
		this.createTimeStr = createTimeStr;
	}

	public void setLogTimeStr(final String logTimeStr) {
		this.logTimeStr = logTimeStr;
	}

}